<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>simpleTemplateCompiler</title>
</head>

<body>
    <div id="text"></div>
    <script>
        const simpleTemplateCompiler = template => data =>
            template.replace(/\{\{(.*?)\}\}/g, (match, key) => data[key.trim()]);
        document.getElementById('text').textContent = simpleTemplateCompiler('{{ year }}-{{ month }}-{{ day }}')({
            year: '2021',
            month: '06',
            day: '08'
        });
    </script>
</body>

</html>